<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
    <meta charset="UTF-8">
    <title>志愿服务</title>
    <meta name="page-view-size" content="1280*720">
    <link rel="stylesheet" href="../css/base.css">
    <link rel="stylesheet" href="../css/volunteer.css">
    <script type="text/javascript" src="../lib/js/evm.js"></script>
    <script type="text/javascript" src="../lib/js/Evm_djyw.js"></script>
    <script type="text/javascript" src="../lib/js/key.js"></script>
    <script src="../lib/js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/api.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/public.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/js/md5.js"></script>
    <style>

    </style>
</head>

<body>
    <div class="volunteer-bg" id="volunteerMain">
        <ul class="nav-bg" id="nav-bg">
        </ul>

        <!-- 下左侧模块 -->
        <ul id="menu_bg" class="menu-bg">



        </ul>


        <div class="list-bg">
            <div class="list-con" id="list-con"></div>
            <p class="page-show"><span id="now_page">0</span>/<span id="total_page">0</span>

            </p>
        </div>

    </div>

    </div>

</body>
<script>
    var modelIndex = {
        index: 0, //导航栏初始位置
        menuKey: '',
        menuPageSize: 5, //导航栏模块数量
        pageSize: 1, //主模块数量
        type: '',
        crumbs: '志愿服务',
        structure: 2, //上下结构  默认1是左右，2是上下结构
        menuContainerId: 'nav-bg', //包含导航栏模块的标签id
        menuListName: 'nav', //导航栏模块名称class
        mainContainerId: 'list-con', //包含主模块的标签id
        mainlistName: '', //主模块名称
        id: 'volunteer',
    }

    var leftData = [
        // {
        //     name: '特色活动', //name
        //     id: '284', //唯一标识
        //     type_style: '1', //类别
        //     size: '4', //数量  
        //     list_name: 'list-row' //右侧模块classname
        // },

        {
            name: '志愿者活动', //name
            id: '0', //唯一标识
            type_style: '3', //类别
            size: '8', //数量  
            list_name: 'list-activity', //右侧模块classname
            // is_cur: 'true'
            rowHeight: 4,
        },
        {
            name: '志愿者招募', //name
            id: '3', //唯一标识
            type_style: '3', //类别
            size: '8', //数量  
            list_name: 'list-activity', //右侧模块classname
            // is_cur: 'true'
            rowHeight: 4,
        },

        {
            name: '志愿者风采', //name
            id: '1019', //唯一标识
            type_style: '3', //类别
            size: '8', //数量  
            list_name: 'list-video', //右侧模块classname,
            is_cur: 'true',
        },
        // {
        //     name: '服务点单', //name
        //     id: '302', //唯一标识
        //     type_style: '3', //类别
        //     size: '12', //数量  
        //     list_name: 'list-type', //右侧模块classname
        //     rowHeight: 4,
        //     menuList: [{
        //             title: '教育服务',
        //             id: '319'
        //         },
        //         {
        //             title: '文化服务',
        //             id: '354'
        //         },
        //         {
        //             title: '社会治理',
        //             id: '358'
        //         },
        //         {
        //             title: '创业就业',
        //             id: '359'
        //         },
        //         {
        //             title: '政策理论宣讲',
        //             id: '315'
        //         },
        //         {
        //             title: '科技与科普服务',
        //             id: '321'
        //         },
        //         {
        //             title: '健康促进与体育服务',
        //             id: '322'
        //         },

        //     ]
        // },
    ];




    function getMenus(page, number) {
        if (typeof number == 'number') {
            // modelIndex.mainContainerId = leftData[number].list_name;
        }
        left.paint(page, number);

    }

    function getMessage(id, page, pos, index) { //id,类型，页码，上下页，位置
        // console.log(id, page, pos, index, modelIndex.menuKey)
        var params = {
            cid: id,
            page: page,
            pagesize: modelIndex.pageSize,
            // month: modelIndex.menuKey || ''
            // area_id: $.cookie('TV_CST_AREA')
        }

        if (id == '3' || id == '0') {
            if (id == '3') {
                var url = 'volunteerGroupList'
            } else if (id == '0') {
                var url = 'getActivityList'
            }
            GetDatas(url, params, function (res, data) {
                var mess = data.data;
                console.log(mess.items, 111111111111)
                var str = '';
                if (mess.items.length) {
                    $('.page-show').css('display', 'block')
                    for (var i = 0; i < mess.items.length; i++) {
                        str += '<div class="' + modelIndex.mainlistName + '" data-id=' + mess.items[i].id +
                            " data-tpe=" + mess.items[i].tpe + " >";
                        if (id == '3') {
                            if (mess.items[i].logo != "") {
                                str += "<img class='list-img' src=" + API_URL.imgURL + mess.items[i].logo + ">"
                            } else {
                                str += '<img src="../images/moren.png" alt="">'
                            }
                            str += '<div class="">"' + mess.items[i].title + '"</div>'
                        } else if (id == '0') {
                            if (mess.items[i].images != "") {
                                str += "<img class='list-img' src=" + API_URL.imgURL + mess.items[i].images +
                                    ">"
                            } else {
                                str += '<img src="../images/moren.png" alt="">'
                            }
                            str += '<div class="">"' + mess.items[i].title + '"</div>'
                            if (mess.items[i].status == '2') {
                                str += '<div><img src="../images/icon-2.png" alt=""></div>'
                            } else if (mess.items[i].status == '1') {
                                str += '<div><img src="../images/icon-1.png" alt=""></div>'
                            } else {
                                str += '<div><img src="../images/icon-0.png" alt=""></div>'
                            }

                        }




                        str += '</div>'
                    }
                } else {
                    str = '<h1>暂无数据</h1>'
                    $('.page-show').css('display', 'none')
                }
                $('#' + modelIndex.mainContainerId).html(str);
                MessOpt(page, mess.totalpage, pos, index);
            })
        } else if (id == 302) {
            console.log(modelIndex.menuKey)
            GetDatas('getCate', {
                id: modelIndex.menuKey || 319
            }, function (res, data) {
                console.log(data.data)
                var str = '';
                var mess = data.data;
                var allpage = mess.length % 12 ? mess.length / 12 + 1 : mess.length / 12
                var items = mess.slice((page - 1) * 12, page * 12);
                if (items.length) {
                    for (var i = 0; i < items.length; i++) {
                        str += '<div class="' + modelIndex.mainlistName + '" data-id=' + items[i].id + ">" +
                            items[i].title + '</div>'
                    }
                }

                // $('.page-show').css('display', 'none')
                $('#' + modelIndex.mainContainerId).html(str);
                MessOpt(page, parseInt(allpage), pos, index);
            })
        } else {
            GetDatas('getArticleList', params, function (res, data) {
                var mess = data.data;
                // console.log(mess.items)
                var str = '';
                if (mess.items.length) {
                    for (var i = 0; i < mess.items.length; i++) {
                        str += '<div class="' + modelIndex.mainlistName + '" data-id=' + mess.items[i].id +
                            " data-tpe=" + mess.items[i].tpe + " >";

                        var img = '';
                        if (mess.items[i].img == '') {
                            img = '../images/base1.jpg'
                        } else {
                            img = API_URL.imgURL + mess.items[i].img
                        }
                        str += '<div class="listImgBar">'
                        str += "<img class='list-img' src=" + img + ">";
                        str += '</div>'
                        if (modelIndex.mainlistName == "list-row") {
                            str += '<div class="list-message"><p class="ell">' + mess.items[i].title + '</p>'
                            str += '<div class="list-brief "><p class="ell">' + mess.items[i].brief +
                                '</p><p>' + mess.items[i].add_time + '</p></div>'
                            str += '</div>'
                        } else if (modelIndex.mainlistName == "list-video") {
                            if (mess.items[i].tpe == 5 || mess.items[i].tpe == 4) {
                                str += "<div class='listPlay' ><img src='../images/play.png'></div>";
                            }
                            str += "<p><span class='ell'>" + mess.items[i].title +
                                "</span><img class='cur' src='../images/goodWhite.png'/><span class='cur-number'>" +
                                mess.items[i].likes + "<span></p>";
                        }
                        str += '</div>'
                    }
                } else {
                    str = '<h1>暂无数据</h1>'
                    $('.page-show').css('display', 'none')
                }
                $('#' + modelIndex.mainContainerId).html(str);
                MessOpt(page, mess.totalpage, pos, index);
            })
        }


    }

    function direEnter(status, id, index) {
        if (status == 0) {
            var access_token = $.cookie('TV_CST_TOKEN');
            var ids = $('.list-video').eq(index).attr('data-id');
            // alert(ids)
            if (access_token == '' || access_token == null) {
                TV.PromptMsg("请登录")
                setTimeout(function () {
                    window.location.href = "login.html";
                }, 2000)
            } else {
                var param = {
                    access_token: access_token,
                    id: ids,
                }
                GetDatas('dianzan', param, function (err, res) {
                    if (res.code == 0) {
                        TV.PromptMsg('点赞成功')
                        $(".cur-number").eq(index).html(res.data.likes);
                    } else if (res.code == 10009) {

                        TV.userLogin();
                        direEnter(index);
                        // alert('111')
                    } else {
                        var message = res.message
                        TV.PromptMsg(message)
                    }
                })
            }

            new TV.CookieOpt().clean();
        } else {
            if (id == 3) {
                window.location.href = "zhaomuDetail.html?id=" + $('.active').attr('data-id');
                return
            }
            if (id == 0) {
                window.location.href = "activeDetail.html?id=" + $('.active').attr('data-id');
                return
            }
            if (id == 302) {
                window.location.href = "sesameList.html?id=" + $('.active').attr('data-id');
                return
            }
            var tpe = $('.active').attr('data-tpe');
            if (tpe == 4 || tpe == 5) {
                window.location.href = 'play.html?id=' + $('.active').attr('data-id');
            } else if (tpe == 1 || tpe == 2 || tpe == 3) {
                // if (tpe == 3) {
                //     window.location.href = './carrousel.html?id=' + $('.active').attr('data-id')
                //     return
                // }
                var locaName = tpe == 1 ? 'word' : 'article'
                window.location.href = locaName + 'Detail.html?id=' + $('.active').attr('data-id') + '&type=' + $(
                    '.focus_menu').attr('data-id');
            }
        }



    }
</script>
<script type="text/javascript" src="../js/twoPageList.js"></script>

</html>